package com.mt.demo.controller;

import com.mt.demo.domain.AjaxResult;
import com.mt.demo.domain.MtVoteRecord;
import com.mt.demo.domain.TableDataInfo;
import com.mt.demo.service.IMtVoteRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 投票记录Controller
 * 
 * @author gary
 * @date 2025-08-11
 */
@RestController
@RequestMapping("/mt/mtRecord")
public class MtVoteRecordController extends BaseController
{
    @Autowired
    private IMtVoteRecordService mtVoteRecordService;

    /**
     * 查询投票记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MtVoteRecord mtVoteRecord)
    {
        startPage();
        List<MtVoteRecord> list = mtVoteRecordService.selectMtVoteRecordList(mtVoteRecord);
        return getDataTable(list);
    }

    /**
     * 导出投票记录列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, MtVoteRecord mtVoteRecord)
    {
        List<MtVoteRecord> list = mtVoteRecordService.selectMtVoteRecordList(mtVoteRecord);
//        ExcelUtil<MtVoteRecord> util = new ExcelUtil<MtVoteRecord>(MtVoteRecord.class);
//        util.exportExcel(response, list, "投票记录数据");
    }

    /**
     * 获取投票记录详细信息
     */
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(mtVoteRecordService.selectMtVoteRecordByRecordId(recordId));
    }

    /**
     * 新增投票记录
     */
    @PostMapping
    public AjaxResult add(@RequestBody MtVoteRecord mtVoteRecord)
    {
        return toAjax(mtVoteRecordService.insertMtVoteRecord(mtVoteRecord));
    }

    /**
     * 修改投票记录
     */
    @PutMapping
    public AjaxResult edit(@RequestBody MtVoteRecord mtVoteRecord)
    {
        return toAjax(mtVoteRecordService.updateMtVoteRecord(mtVoteRecord));
    }

    /**
     * 删除投票记录
     */
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(mtVoteRecordService.deleteMtVoteRecordByRecordIds(recordIds));
    }
}
